package org.ace.dao.impl;

import java.util.List;

import org.ace.dao.IPlayerItemDAO;
import org.ace.dao.model.PlayerItem;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class PlayerItemDAOImpl extends SqlMapClientDaoSupport implements IPlayerItemDAO {

    public PlayerItemDAOImpl() {
        super();
    }

    public void save(PlayerItem playeritem) {
        getSqlMapClientTemplate().insert("playeritem.insert", playeritem);
    }

    public int update(PlayerItem playeritem) {
        int rows = getSqlMapClientTemplate().update("playeritem.update", playeritem);
        return rows;
    }

    public PlayerItem get(Integer itemid) {
    	PlayerItem key = new PlayerItem();
        key.setItemid(itemid);
        PlayerItem record = (PlayerItem) getSqlMapClientTemplate().queryForObject("playeritem.select", key);
        return record;
    }

    public int remove(Integer itemid) {
    	PlayerItem key = new PlayerItem();
        key.setItemid(itemid);
        int rows = getSqlMapClientTemplate().delete("playeritem.delete", key);
        return rows;             
    }
    
    public List<PlayerItem> getList(Integer userId)
    {
        	@SuppressWarnings("unchecked")
			List<PlayerItem> list=(List<PlayerItem>)getSqlMapClientTemplate().queryForList("playeritem.selectByUserId", userId);
        	return list;
    }
}